//
//  Insure_ViewController.m
//  EggSteward
//
//  Created by 王道林 on 16/9/1.
//  Copyright © 2016年 王道林. All rights reserved.
//

#import "Insure_ViewController.h"
#import "BaseTableView.h"
#import "BaseView.h"
#import "BaseButton.h"
#import "Insure_tableViewCell.h"
@interface Insure_ViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) BaseTableView *tableView;
@end

@implementation Insure_ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"蛋鸡保险";
    [self createSubView];
    
}
- (void)createSubView
{
    _tableView = [[BaseTableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 64 - 49) style:UITableViewStylePlain];
    _tableView.backgroundColor = [UIColor colorWithWhite:0.909 alpha:1.000];
    [self createTableViewFootView];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [self.view addSubview:_tableView];
    [_tableView registerClass:[Insure_tableViewCell class] forCellReuseIdentifier:@"reuseOne"];
}
#pragma mark - tableView的协议方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 700;
}
// 返回cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    Insure_tableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuseOne" forIndexPath:indexPath];
    cell.blockBegenText = ^()
    {
        [UIView beginAnimations:@"wang" context:nil];
        [UIView setAnimationDuration:0.3];
        _tableView.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height - 216);
        [UIView commitAnimations];
    };
    cell.blockEndText = ^()
    {
        [UIView beginAnimations:@"wang" context:nil];
        [UIView setAnimationDuration:0.3];
        _tableView.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height);
        [UIView commitAnimations];

    };
    return cell;
}

// 头的标题
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    return @"鸡场信息:";
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 30;
}

#pragma mark - 创建tableView的尾视图
- (void)createTableViewFootView
{
    BaseView *view = [[BaseView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)];
    view.backgroundColor = [UIColor colorWithWhite:0.909 alpha:1.000];
    _tableView.tableFooterView = view;
    BaseButton *button = [BaseButton buttonWithType:UIButtonTypeSystem];
    [view addSubview:button];
    button.frame = CGRectMake(30, 0, self.view.frame.size.width - 60, 35);
    [button setBackgroundColor:[UIColor colorWithRed:0.157 green:0.651 blue:0.278 alpha:1.000]];
    button.layer.masksToBounds = YES;
    button.layer.cornerRadius = 17.5;
    [button setTitle:@"下一步" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
